<template>
  <div class="auth-page">
    <!-- 空白页面内容 -->
    <page-permission v-if="isPermission" :title="title"></page-permission>
  </div>
</template>

<script setup>
// 空白页面逻辑
import { ref, onMounted, onUnmounted } from 'vue';
import { setKeyItem, getToken } from '@/utils/auth'
import { useRouter } from 'vue-router'
import { taskPage, logion } from '@/api/api'
import pagePermission from '../task/component/permission.vue'
const router = useRouter()
const isPermission = ref(false)
const title = ref('')
const getInit = () => {
  dd.ready(function () {
    dd.getAuthCode({
    corpId: 196729
    }).then(data => {
      console.log('--------getAuthCode-------', data)
      logion({
        authCode: data.code
      }).then(res => {
        console.log('-----------获取到用户信息---------------', res.resData)
        setKeyItem('token', res.resData.token)
        router.replace('/task')
      }).catch(() => {
        isPermission.value = true
      })
    }).catch(err => {
      title.value = "请使用浙政钉扫码"
      isPermission.value = true 
    })
  })
}


onMounted(() => {
  getInit()
})
</script>

<style scoped>
.auth-page {
  /* 空白页面样式 */
}
</style>
